package com.zj.web.controller;

import com.zj.service.BannerService;
import com.zj.web.bean.BannerDTO;
import com.zj.web.bean.ResponseResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/auth/banner")
@RefreshScope //开启动态刷新
@Tag(name = "轮播图控制器",description = "提供对轮播图资源的添加，查询并显示等操作")
public class AuthBannerController {
    @Autowired
    private BannerService bannerService;
    /**
     * 前台：根据状态查询轮播图，按bannerid降序
     * */
    @GetMapping("/getBannersByStatus/{bannerStatus}")
    public ResponseEntity<ResponseResult> getBannersByStatus(@PathVariable("bannerStatus") Integer bannerStatus){
        List<BannerDTO> bannerList = bannerService.getBannersByStatus(bannerStatus);
        return ResponseEntity.ok(ResponseResult.ok().setdata(bannerList));
    }
}
